package com.shitou.shitouproduct.controller;


import java.util.Arrays;
import java.util.Map;

import com.shitou.shitouproduct.entity.AttrAttrgroupRelationEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.shitou.shitouproduct.service.AttrAttrgroupRelationService;
import com.shitou.shitoucommons.utils.PageUtils;
import com.shitou.shitoucommons.utils.RespBean;



/**
 * 属性&属性分组关联
 *
 * @author 石头人
 * @email 3076767823@qq.com
 * @date 2023-03-04 18:03:45
 */
@RestController
@RequestMapping("shitouproduct/attrattrgrouprelation")
public class AttrAttrgroupRelationController {
    @Autowired
    private AttrAttrgroupRelationService attrAttrgroupRelationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public RespBean list(@RequestParam Map<String, Object> params){
        PageUtils page = attrAttrgroupRelationService.queryPage(params);

        return RespBean.success().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public RespBean info(@PathVariable("id") Long id){
        AttrAttrgroupRelationEntity attrAttrgroupRelation = attrAttrgroupRelationService.getById(id);

        return RespBean.success().put("attrAttrgroupRelation", attrAttrgroupRelation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public RespBean save(@RequestBody AttrAttrgroupRelationEntity attrAttrgroupRelation){
        attrAttrgroupRelationService.save(attrAttrgroupRelation);

        return RespBean.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public RespBean update(@RequestBody AttrAttrgroupRelationEntity attrAttrgroupRelation){
        attrAttrgroupRelationService.updateById(attrAttrgroupRelation);

        return RespBean.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public RespBean delete(@RequestBody Long[] ids){
        attrAttrgroupRelationService.removeByIds(Arrays.asList(ids));

        return RespBean.success();
    }



}
